<?php

/**
 * 后台路由
 */

/**后台模块**/
Route::group(['namespace' => 'Admin','prefix' => 'admin'], function (){

    Route::get('login','AdminsController@showLoginForm')->name('login');  //后台登陆页面

    Route::post('login-handle','AdminsController@loginHandle')->name('login-handle'); //后台登陆逻辑

    Route::get('logout','AdminsController@logout')->name('admin.logout'); //退出登录

    /**需要登录认证模块**/
    Route::middleware(['auth:admin','rbac'])->group(function (){

        Route::resource('index', 'IndexsController', ['only' => ['index']]);  //首页

        Route::get('index/main', 'IndexsController@main')->name('index.main'); //首页数据分析

        Route::get('admins/status/{statis}/{admin}','AdminsController@status')->name('admins.status');

        Route::get('admins/delete/{admin}','AdminsController@delete')->name('admins.delete');

        Route::resource('admins','AdminsController',['only' => ['index', 'create', 'store', 'update', 'edit']]); //管理员

        Route::get('roles/access/{role}','RolesController@access')->name('roles.access');

        Route::post('roles/group-access/{role}','RolesController@groupAccess')->name('roles.group-access');

        Route::resource('roles','RolesController',['only'=>['index','create','store','update','edit','destroy'] ]);  //角色

        Route::get('rules/status/{status}/{rules}','RulesController@status')->name('rules.status');

        Route::resource('rules','RulesController',['only'=> ['index','create','store','update','edit','destroy'] ]);  //权限

        Route::resource('actions','ActionLogsController',['only'=> ['index','destroy'] ]);  //日志
        
        Route::get('agent/index', 'AgentController@index')->name('agent.index'); //代理商管理
        
        Route::get('agent/create', 'AgentController@create')->name('agent.create'); 
        
        Route::post('agent/store', 'AgentController@store')->name('agent.store'); 
        
        Route::get('agent/edit/{agent}','AgentController@edit')->name('agent.edit'); //代理商编辑
        
        Route::patch('agent/update/{id}','AgentController@update')->name('agent.update');
        
        Route::get('agent/state/{state}/{agent}','AgentController@state')->name('agent.state');
        
        Route::get('agent/delete/{agent}','AgentController@delete')->name('agent.delete');

        Route::get('finance/index', 'FinanceController@index')->name('finance.index'); //财务公司管理
        
        Route::get('finance/create', 'FinanceController@create')->name('finance.create');

        Route::post('finance/store', 'FinanceController@store')->name('finance.store');
        
        Route::get('finance/edit/{finance}','FinanceController@edit')->name('finance.edit'); //财务公司编辑

        Route::patch('finance/update/{id}','FinanceController@update')->name('finance.update');

        Route::get('finance/state/{state}/{finance}','FinanceController@state')->name('finance.state');

        Route::get('finance/delete/{finance}','AgentController@delete')->name('finance.delete');

        Route::get('bill/finance/{bill}','BillController@finance')->name('bill.finance'); //账单明细列表-财务公司
        
        Route::get('bill/agent/{bill}','BillController@agent')->name('bill.agent'); //账单明细列表-代理商
        
        Route::get('bill/export','BillController@export')->name('bill.export'); //导出账单
        
        Route::get('accounting/index','AccountingController@index')->name('accounting.index'); //企业账薄
        
        Route::get('accounting/details/{accounting}','AccountingController@details')->name('accounting.details');

        Route::get('financial/index', 'FinancialController@index')->name('financial.index'); //财务管理
        
        Route::get('financial/detail', 'FinancialController@detail')->name('financial.detail');

        Route::get('financial/create', 'FinancialController@create')->name('financial.create');
        
        Route::get('financial/order', 'FinancialController@order')->name('financial.order'); //查看订单
        
        Route::get('financial/create', 'FinancialController@create')->name('financial.create'); //生成订单
        
        Route::patch('financial/create', 'FinancialController@create')->name('financial.create');
        
        Route::get('financial/sure', 'FinancialController@sure')->name('financial.sure'); 
        
        Route::get('settings/index','SettingsController@index')->name('settings.index'); //费用设置

        Route::get('finance/editPassword/{agent}', 'FinanceController@editPassword')->name('finance.editPassword');

        Route::post('finance/password/{id}', 'FinanceController@password')->name('finance.password');

        Route::get('agent/editPassword/{agent}', 'AgentController@editPassword')->name('agent.editPassword');

        Route::post('agent/password/{id}', 'AgentController@password')->name('agent.password');

        Route::get('finance/sure', 'FinanceController@sure')->name('finance.sure');

        Route::get('financial/sure', 'FinancialController@sure')->name('financial.sure');

        Route::get('financial/order', 'FinancialController@order')->name('financial.order');
	});
});
